package com.ushine.web.log.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @Author: yls
 * @Date: 2020/10/20 00:09
 * @Description: 工具类，辅助获取ip地址
 * @Version 1.0
 */
public class HttpContextUtils {
    private HttpContextUtils() {

    }

    public static HttpServletRequest getHttpServletRequest() {
        return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
    }
}
